package Controller;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import Jdbc.JdbcSedat;
import Model.Uye;

import com.opensymphony.xwork2.ActionSupport;

public class UyeOl extends ActionSupport{

	private String ad;
	private String soyad;
	private String e_mail;
	private String sifre;
	private String dogum_yeri;
	private String dogum_tarihi;
	private String meslek;
	private String uzmanlik_alani;
	private String unvan;
	private String ozgecmis;
	private int rol_enable;
	private String rol_secimi;
	private String sonuc;
	private InputStream inputStream;
	
	public String uyeOl() throws UnsupportedEncodingException{
		
		Uye uye=JdbcSedat.uyeOl(ad,soyad,e_mail,sifre,dogum_yeri,dogum_tarihi,meslek,uzmanlik_alani,unvan,ozgecmis,rol_enable,rol_secimi);
		if(uye!=null){
			sonuc = "basarili_giris";
			setSession("uye", uye);
		}
		
		inputStream = new ByteArrayInputStream(sonuc.getBytes("UTF-8"));
		return SUCCESS;
	}
	
	private static void setSession(String key, Object obj) {
		HttpSession session = ServletActionContext.getRequest().getSession();
		session.setAttribute(key, obj);
	}
	
	
	public InputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}

	public String getSonuc() {
		return sonuc;
	}

	public void setSonuc(String sonuc) {
		this.sonuc = sonuc;
	}

	public String getAd() {
		return ad;
	}
	public void setAd(String ad) {
		this.ad = ad;
	}
	public String getSoyad() {
		return soyad;
	}
	public void setSoyad(String soyad) {
		this.soyad = soyad;
	}
	public String getE_mail() {
		return e_mail;
	}
	public void setE_mail(String e_mail) {
		this.e_mail = e_mail;
	}
	public String getSifre() {
		return sifre;
	}
	public void setSifre(String sifre) {
		this.sifre = sifre;
	}
	public String getDogum_yeri() {
		return dogum_yeri;
	}
	public void setDogum_yeri(String dogum_yeri) {
		this.dogum_yeri = dogum_yeri;
	}
	public String getDogum_tarihi() {
		return dogum_tarihi;
	}
	public void setDogum_tarihi(String dogum_tarihi) {
		this.dogum_tarihi = dogum_tarihi;
	}
	public String getMeslek() {
		return meslek;
	}
	public void setMeslek(String meslek) {
		this.meslek = meslek;
	}
	public String getUzmanlik_alani() {
		return uzmanlik_alani;
	}
	public void setUzmanlik_alani(String uzmanlik_alani) {
		this.uzmanlik_alani = uzmanlik_alani;
	}
	public String getUnvan() {
		return unvan;
	}
	public void setUnvan(String unvan) {
		this.unvan = unvan;
	}
	public String getOzgecmis() {
		return ozgecmis;
	}
	public void setOzgecmis(String ozgecmis) {
		this.ozgecmis = ozgecmis;
	}
	public int getRol_enable() {
		return rol_enable;
	}
	public void setRol_enable(int rol_enable) {
		this.rol_enable = rol_enable;
	}
	public String getRol_secimi() {
		return rol_secimi;
	}
	public void setRol_secimi(String rol_secimi) {
		this.rol_secimi = rol_secimi;
	}
	
	
	
}
